package com.yj.suncity.setting;

import org.json.JSONObject;

import com.yj.suncity.R;
import com.yj.suncity.async.AsyncTaskUtil;
import com.yj.suncity.async.AsyncTaskUtil.ResultCallBack;
import com.yj.suncity.constant.URLCon;
import com.yj.suncity.utis.ToastUtil;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.widget.TextView;

public class AboutUsActivity extends Activity {
	private Context context;
	private WebView view;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_about_us);
		context = this;
		findView();
		initData();
	}

	private void findView() {
		((TextView) findViewById(R.id.txt_title_name)).setText("关于我们");

		view = (WebView) findViewById(R.id.webView1);
		WebSettings settings = view.getSettings();
		settings.setUseWideViewPort(false);// 设置webview 推荐使用的串口。
		settings.setLoadWithOverviewMode(true);// 设置webview加载页面的方式
		settings.setJavaScriptEnabled(true);// 要与javascript交互
		// settings.setAllowFileAccess(true);//要访问本地文件
		settings.setSupportZoom(true);
		// settings.setBuiltInZoomControls(true);
		// view.setInitialScale(39);
		view.setBackgroundColor(0);// 设置透明颜色
		settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

	}

	private void initData() {
		String path = URLCon.设置 + "?action=about";
		AsyncTaskUtil asyncTaskUtil = new AsyncTaskUtil(context, null, null,
				false, null, true, "正在加载......", new ResultCallBack() {
					@Override
					public void JSONResult(JSONObject jsonObject) {
						if (jsonObject.optString("success").equals("1")) {
							String context = jsonObject.optString("context");
							view.loadDataWithBaseURL(URLCon.HOST, context,
									"text/html", "utf-8", "");

						} else {
							ToastUtil.ShowToast(context,
									jsonObject.optString("msg"));
						}
					}
				});
		asyncTaskUtil.execute(path);
	}

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnHeadBack:
			this.finish();
			break;

		default:
			break;
		}
	}

}
